package com.runa.persistence.map;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 2024/9/14 14:46
 * zhangYB
 */
public class FixedSizeMap<K, V> extends LinkedHashMap<K, V> {




    private final int maxSize;

    public FixedSizeMap(int maxSize) {
        super(16, 0.75f, true); // 初始容量16，加载因子0.75，访问顺序
        this.maxSize = maxSize;
    }

    @Override
    protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
        return size() > maxSize;
    }


    @Override
    public V put(K key, V value) {
        return super.put(key, value);
    }
}
